

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>预约记录</title>
    <link rel="stylesheet" href="/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/assets/module/admin.css?v=315"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .ew-iframe-body {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            overflow: auto;
        }
    </style>
</head>
<body class="ew-iframe-body">

<!-- 页面加载loading -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">关键字：</label>
                        <div class="layui-input-inline mr0">
                            <input name="title" class="layui-input" type="text" placeholder="姓名/手机号码/身份证" lay-verType="tips"   />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">日期：</label>
                        <div class="layui-input-inline mr0">
                            <input name="visitdate" class="layui-input date-icon" type="text" placeholder="请选择日期范围"
                                   autocomplete="off" lay-verType="tips" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn" lay-filter="formSubSearchLog" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="btnExpLog" class="layui-btn icon-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
                         <button id="refresh" class="layui-btn icon-btn layui-btn-danger"><i class="layui-icon">&#xe63d;</i>刷新</button>
                    </div>
                </div>
            </div>

            <table class="layui-table" id="tableLog" lay-filter="tableLog"></table>
        </div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/assets/js/common.js?v=315"></script>
<script>
    layui.use(['layer', 'form', 'table', 'util', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var laydate = layui.laydate;

        // 渲染表格
        var insTb = table.render({
            elem: '#tableLog',
            url: '{:url('index/list')}?key=fslks',
            page: true,
            cellMinWidth: 100,
            title: '登录日志',
            cols: [[
                {type: 'checkbox'},
                {field: 'id', sort: true, title: '编号' ,width: 80},
                {field: 'name', sort: true, title: '姓名',width: 150},
                {field: 'visitdate', sort: true, title: '参观日期',width: 150},
                {field: 'datez', sort: true, title: '时间段',width: 100},
                {field: 'phone', sort: true, title: '手机号码',width: 180},
                {field: 'idcard', sort: true, title: '身份证号码'},
                {field: 'remark', sort: true, title: '其他备注'},
                {
                    field: 'addtime', templet: function (d) {
                        return util.toDateString(d.addtime);
                    }, title: '登录时间'
                }
            ]]
        });

        // 时间范围
        laydate.render({
            elem: 'input[name="visitdate"]',
            type: 'date',
            range: false,
            trigger: 'click'
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            /*
            if (data.field.visitdate) {
                var searchDate = data.field.visitdate.split(' - ');
                data.field.startDate = searchDate[0];
                data.field.endDate = searchDate[1];
            } else {
                data.field.startDate = '';
                data.field.endDate = '';
            }
            data.field.visitdate = undefined;
            */
            insTb.reload({where: data.field}, 'data');
        });

        // 导出excel
        $('#btnExpLog').click(function () {
            var checkRows = table.checkStatus('tableLog');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

        // 刷新
        $('#refresh').click(function () {
             location.reload();
        });



    });
</script>

</body>
</html>